package com.bridgeintelligent.tag.user.query.mapper;


import com.bridgeintelligent.tag.user.mgmt.pojo.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 用户持久层
 */
@Mapper
public interface UserQueryMapper {


    /**
     * 校验用户名是否重复
     *
     * @param username
     * @return
     */
    int checkUserName(String username);

    /**
     * 根据用户名查询用户信息
     *
     * @param username
     * @return
     */
    User findOneByUsername(String username);

    /**
     * 查询所有用户
     *
     * @return
     */
    List<User> findAllUser();

    /**
     * 查询所有用户
     *
     * @return
     */
    @Select("select a.D_NAME as name, a.USER_ID from tag_user a left JOIN (SELECT DISTINCT owner_id FROM tag_customers) b ON a.user_id = b.owner_id where b.owner_id is not null and a.EFFTCTIVE_SYMBOL='01'")
    List<User> findUserList();

    /**
     * 查询所有用户
     *
     * @return
     */
    @Select("select a.D_NAME as name, a.USER_ID from tag_user a  where a.EFFTCTIVE_SYMBOL='01'")
    List<User> findAllUserList();
    /**
     * 分页条件查询
     * @param queryCondition
     * @return
     */
//	Page<User> findPageUser(Map<String,Object> queryCondition);

    /**
     * 查询用户列表
     *
     * @param name
     * @param userPhone
     * @return
     */
    List<User> findList(@Param("name") String name, @Param("userPhone") String userPhone, @Param("userId") String userId);

    /**
     * findOneByUserId
     *
     * @param createrId
     * @return
     */
    String findOneByUserId(String createrId);

    /**
     * findByUserId
     *
     * @param userId
     * @return
     */
    User findByUserId(String userId);
}